home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / language / euphor12 / sanity.ex < prev    next >
Text File  |  1994-04-18  |  17KB  |  851 lines

  1.         ------------------------------------------
  2.         -- AUTOMATIC SELF-CHECKING SANITY TEST  --
  3.         -- for Euphoria                         --
  4.         -- A quick test of most of the features --
  5.         ------------------------------------------
  6. with type_check
  7.  
  8. include get.e
  9. include graphics.e
  10. include sort.e
  11. include machine.e
  12. include file.e
  13.  
  14. trace(0)
  15.  
  16. constant msg = 1 -- place to send messages
  17.  
  18. global object y, i, r
  19.  
  20. procedure the_end()
  21.     abort(1)
  22. end procedure
  23.  
  24. procedure make_sound()
  25. -- test sound() built-in
  26.     for i = 500 to 5000 by 500 do
  27.     sound(i)
  28.     for j = 1 to 100000 do
  29.     end for
  30.     sound(0)
  31.     end for
  32. end procedure
  33.  
  34. without warning
  35. procedure abort()
  36. -- force abort with trace back
  37.     puts(msg, "\ndivide by 0 to get trace back...Press Enter\n")
  38.     if sequence(gets(0)) then
  39.     end if
  40.     ? 1/0
  41. end procedure
  42. with warning
  43.  
  44. procedure show(object x, object y)
  45. -- show the mismatched values
  46.     puts(msg, "\n   ---MISMATCH--- \n   x is ")
  47.     ? x
  48.     puts(msg, "   y is ")
  49.     ? y
  50.     abort()
  51. end procedure
  52.  
  53. constant epsilon = 1e-10 -- allow for small floating point inaccuracy
  54.  
  55. procedure same(object x, object y)
  56. -- object x must be identical to object y else abort program
  57.     atom ratio
  58.  
  59.     if atom(x) and atom(y) then
  60.     if x = y then
  61.         return
  62.     else
  63.         if y = 0 then
  64.         show(x, y)
  65.         else
  66.         ratio = x / y
  67.         if ratio < 1 - epsilon or ratio > 1 + epsilon then
  68.             show(x, y)
  69.         end if
  70.         end if
  71.     end if
  72.     elsif length(x) = length(y) then
  73.     for i = 1 to length(x) do
  74.         same(x[i], y[i])
  75.     end for
  76.     else
  77.     show(x, y)
  78.     end if
  79. end procedure
  80.  
  81. function abs(atom x)
  82. -- absolute value
  83.     if x < 0 then
  84.     return -x
  85.     else
  86.     return x
  87.     end if
  88. end function
  89.  
  90. function built_in()
  91. -- built-in tests
  92.     sequence d
  93.  
  94.     d = date()
  95.     if d[1] < 93 or d[2] > 12 or d[3] < 1 or d[4] > 23 or d[5] > 59 or
  96.     d[6] >59 or d[7] > 7  or d[8] > 366 then
  97.     abort()
  98.     end if
  99.     d = power({-5, -4.5, -1,  0, 1,  2,  3.5, 4, 6},
  100.           { 3,    2, -1,0.5, 0, 29, -2.5, 5, 8})
  101.     if d[1] != -125 or d[2] != 20.25 or d[3] != -1 or d[4] != 0 then
  102.     abort()
  103.     end if 
  104.     if d[5] != 1 or d[6] != 536870912 or d[7] <.043 or d[7] > .044 then
  105.     abort()
  106.     end if
  107.     if d[8] != 1024 or d[9] != 1679616 or power(2,3) != 8 then
  108.     abort()
  109.     end if
  110.     same(power(16, 0.5), 4)
  111.     d = remainder({5, 9, 15, -27}, {3, 4, 5, 6})
  112.     if d[1] != 2 or d[2] != 1 or d[3] != 0 or d[4] != -3 then
  113.     abort()
  114.     end if
  115.     d = remainder({11.5, -8.8, 3.5, 5.0}, {2, 3.5, -1.5, -100.0})
  116.     if d[1] != 1.5 or d[2] < -1.81 or d[2] > -1.79 or d[3] != 0.5 or d[4] != 5 then
  117.     abort()
  118.     end if
  119.     same(4, sqrt(16))
  120.     same(3, length("ABC"))
  121.     same({1, 1, 1, 1}, repeat(1, 4))
  122.     if rand(10) > 10 or rand(20) < 1 or not find(rand(5.5), {1,2,3,4,5}) then
  123.     abort()
  124.     end if
  125.     if time() < 0 then
  126.     abort()
  127.     end if
  128.     if abs(sin(3.1415)) > 0.02 then
  129.     abort()
  130.     end if
  131.     if cos(0) < .98 then
  132.     abort()
  133.     end if
  134.     if abs(tan(3.14/4) - 1) > .02 then
  135.     abort()
  136.     end if
  137.     if log(2.7) < 0.8 or log(2.7) > 1.2 then
  138.     abort()
  139.     end if
  140.     if floor(-3.3) != -4 then
  141.     abort()
  142.     end if
  143.     if floor(-999/3.000000001) != -333 then
  144.     abort()
  145.     end if
  146.     if floor(9.99/1) != 9 then
  147.     abort()
  148.     end if
  149.     for i = -9 to 2 do
  150.     if i = 1 then
  151.         return i
  152.     end if
  153.     end for
  154. end function
  155.  
  156. procedure sub()
  157.     y = 200
  158. end procedure
  159.  
  160. procedure overflow()
  161. -- test overflows from integer into floating point
  162.     object two29, two30, maxint, prev_i
  163.     integer two30i, mtwo30i
  164.     sequence s
  165.  
  166.     two30 = 1
  167.     for i = 1 to 30 do
  168.     two30 = two30 * 2
  169.     end for
  170.     s = {two30, two30+1, two30+2}
  171.     s = s + s
  172.     if compare(s, {two30*2, two30*2+2, two30*2+4}) then
  173.     abort()
  174.     end if
  175.     mtwo30i = -1
  176.     for i = 1 to 29 do
  177.     mtwo30i = mtwo30i * 2
  178.     end for
  179.     two30i = 1
  180.     for i = 1 to 29 do
  181.     two30i = two30i * 2
  182.     end for
  183.     if 2 * two30i != -2 * mtwo30i then
  184.     abort()
  185.     end if
  186.     if two30i*2 != two30 then
  187.     abort()
  188.     end if
  189.     two29 = floor(two30 / 2)
  190.     if two29 + two29 != two30 then
  191.        abort()
  192.     end if
  193.  
  194.     maxint = floor(two30 - 1)
  195.     if maxint + 1 != two30 then
  196.     abort()
  197.     end if
  198.  
  199.     if 2 + maxint != two30 + 1 then
  200.     abort()
  201.     end if
  202.  
  203.     if (-maxint - 1) * -1 != two30 then
  204.     abort()
  205.     end if
  206.  
  207.     prev_i = -maxint + 1
  208.     for i = -maxint to -maxint -5 by -1 do
  209.     if i != prev_i - 1 then
  210.         abort()
  211.     end if
  212.     prev_i = i
  213.     end for
  214.  
  215.     prev_i = maxint - 5
  216.     for i = maxint - 3 to maxint + 3 by 2 do
  217.     if i != prev_i + 2 then
  218.         abort()
  219.     end if
  220.     prev_i = i
  221.     end for
  222.  
  223.     if floor(two30) != two30 then
  224.     abort()
  225.     end if
  226.  
  227.     if floor(two30 + two30 - 1) != two30 * 2 - 1 then
  228.     abort()
  229.     end if
  230. end procedure
  231.  
  232. type natural(integer x)
  233.     return x >= 0
  234. end type
  235.  
  236. procedure atomic_ops()
  237. -- test operations on atoms
  238.     object a, x, z
  239.     integer n, m
  240.     natural p
  241.  
  242.     p = 0
  243.     p = 0.000
  244.     p = 4.0/2.0
  245.     if p != 2.0 then
  246.     abort()
  247.     end if    
  248.     n = 1
  249.     m = 1
  250.     if n and m then
  251.     else
  252.     abort()  
  253.     end if
  254.  
  255.     x = 100
  256.     sub() -- y = 200
  257.     z = 300
  258.  
  259.     if x + y != z then
  260.     abort()
  261.     end if
  262.  
  263.     if x != 100 then
  264.     abort()
  265.     end if
  266.  
  267.     if 3 * 3 != 9 or
  268.        3 * 900000000 != 2700000000 or
  269.        15000 * 32000 != 480000000 or
  270.        32000 * 15000 != 480000000 or
  271.        1000 * 13000 != 13000000 or
  272.        13000 * 1000 != 13000000 then
  273.     abort()
  274.     end if
  275.     while x != 100 do
  276.     abort()
  277.     end while
  278.  
  279.     if not (z - y = 100) then
  280.     abort()
  281.     end if
  282.  
  283.     if #FFFFFFFF != 4294967295 then
  284.     abort()
  285.     end if
  286.    
  287.     p = 20
  288.     while not (p < 10) do
  289.     p = p - 2    
  290.     end while
  291.     if p != 8 then
  292.     abort()
  293.     end if
  294.  
  295.     if x * 1000.5 != 100050 or x * y != 20000 or x / y != 0.5 then
  296.     abort()
  297.     end if
  298.  
  299.     if y < x then
  300.     abort()
  301.     end if
  302.  
  303.     if y <= x then
  304.     abort()
  305.     end if
  306.  
  307.     if x > y then
  308.     abort()
  309.     end if
  310.  
  311.     if x >= y then
  312.     abort()
  313.     end if
  314.  
  315.     if -x != -100 then
  316.     abort()
  317.     end if
  318.  
  319.     if x = x and y > z then
  320.     abort()
  321.     end if
  322.  
  323.     x = 0
  324.  
  325.     y = {"ten", "one", "two", "three", "four", "five", "six", "seven", "eight",
  326.      "nine", "ten", "ten"}
  327.  
  328.     while x <= 11 do
  329.     if x = 1 then a = "one"
  330.     elsif x = 2 then a = "two"
  331.     elsif x = 3 then a = "three"
  332.     elsif x = 4 then a = "four"
  333.     elsif x = 5 then a = "five"
  334.     elsif x = 6 then a = "six"
  335.     elsif x = 7 then a = "seven"
  336.              if 1 + 1 = 2 then
  337.                  same(a, "seven")
  338.              elsif 1 + 1 = 3 then
  339.                  abort()
  340.              else
  341.                  abort()
  342.              end if
  343.     elsif x = 8 then a = "eight"
  344.     elsif x = 9 then a = "nine"
  345.     else a = "ten"
  346.     end if
  347.     same(a, y[1+x])
  348.     x = x + 1
  349.     end while
  350.  
  351.     y = 0
  352.     for xx = 100 to 0 by -2 do
  353.     y = y + xx
  354.     end for
  355.     same(y, 50 * 51)
  356.  
  357.     for xx = 1 to 10 do
  358.     if xx = 6 then
  359.         x = 6
  360.         exit
  361.     end if
  362.     y = 1
  363.     while y < 25 do
  364.         y = y + 1
  365.         if y = 18 then
  366.         exit
  367.         end if
  368.     end while
  369.     same(y, 18)
  370.     end for
  371.     y = repeat(-99, 7)
  372.     for xx = +3 to -3 by -1 do
  373.     y[xx+4] = xx
  374.     end for
  375.     same(y, {-3, -2, -1, 0, +1, +2, +3})
  376.  
  377.     y = {1,2,3}
  378.     for xx = 1.5 to +3.0 by .5 do
  379.       y[xx] = xx
  380.     end for
  381.     same(y, {1.5, 2.5, 3.0})
  382.     y = {}
  383.     for xx = -9.0 to -9.5 by -.25 do
  384.       y = y & xx
  385.     end for
  386.     same(y, {-9, -9.25, -9.5})
  387.     y = {}
  388.     for i = 800000000 to 900000000 by 800000000 do
  389.     y = append(y, i)    
  390.     end for
  391.     if compare(y, {800000000}) then
  392.     abort()
  393.     end if
  394.     y = 5
  395.     n = 3
  396.     a = 2
  397.     for i = 1 to y by a do
  398.     n = n - 1
  399.     y = 155
  400.     a = 1
  401.     end for
  402.     same(n, 0)
  403. end procedure
  404.  
  405. procedure floating_pt()
  406. -- test floating-point operations
  407.     sequence x
  408.     atom final
  409.  
  410.     x = {1.5, -3.5, 1e10, -1e20, 0.0, 0.0001}
  411.     y = repeat(x, 10)
  412.     if x[1]/x[2] > -0.42 or x[1]/x[2] < -0.43 then
  413.     abort()
  414.     end if
  415.     if find(1e10, x) != 3 then
  416.     abort()
  417.     end if
  418.     for a = -1.0 to sqrt(999) by 2.5 do
  419.     if a > 20.0 then
  420.         final = a
  421.         exit
  422.     end if
  423.     end for
  424.     if final < 20.0 or final > 23 then
  425.     abort()
  426.     end if
  427. end procedure
  428.  
  429. function one()
  430.     return 1
  431. end function
  432.  
  433. function two()
  434.     return 2.000
  435. end function
  436.  
  437. function sequence_ops()
  438. -- test operations on sequences
  439.     object i, w, x, y, z
  440.     sequence s
  441.     integer j
  442.  
  443.     x = "Hello "
  444.     y = "World"
  445.  
  446.     if find(0, x = x) then
  447.     abort()
  448.     end if
  449.     if x[two()*two() - two()] != 'e' then
  450.     abort()
  451.     end if
  452.     if x[one()+one()] != x[two()] then
  453.     abort()
  454.     end if
  455.  
  456.     j = x[1]
  457.     if j != 'H' then
  458.     abort()
  459.     end if
  460.     s = {3.0}
  461.     s[1] = 1.0000
  462.     j = s[1]
  463.     if j != 1 then
  464.     abort()
  465.     end if
  466.     i = 1
  467.     if not atom(i) or not integer(i) then 
  468.     abort()
  469.     end if
  470.     if length(y) != 5 then 
  471.     abort()
  472.     end if
  473.     while i <= 5 do
  474.     x = append(x, y[i])
  475.     i = i + 1
  476.     end while
  477.     i = 1
  478.     while i <= 3 do
  479.     x = append(x, '.')
  480.     x = append(x, '\'')
  481.     i = i + 1
  482.     end while
  483.     same(x, "Hello World.'.'.'")
  484.     x = repeat(5, 19)
  485.     x = append(x, 20)
  486.     x[7] = 9
  487.     y = {9, 9, {9}}
  488.     y = prepend(y, 8)
  489.     y = prepend(y, {9, 9})
  490.     same(y, {{9, 9}, 8, 9, 9, {9}})
  491.     y = x
  492.     z = y * x + x + 1000
  493.     w = z > 1030 or x = 9
  494.     same(z, {1030, 1030, 1030, 1030, 1030, 1030, 1090, 1030, 1030, 1030,
  495.          1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1420})
  496.     same(w, {0, 0, 0, 0, 0, 0, 1, 0, 0, 0,
  497.          0, 0, 0, 0, 0, 0, 0, 0, 0, 1})
  498.     x = {100, 200, {1, 2, {0, 0, 0}}, 300}
  499.     x[3][3][3] = 25
  500.     x = x * x
  501.     same(x, {10000, 40000, {1, 4, {0, 0, 625}}, 90000})
  502.     y = x / {1, 2, 3, 4}
  503.     same(y, {10000, 20000, {1/3, 4/3, {0, 0, 625/3}}, 22500})
  504.     -- & tests
  505.  
  506.     same(2 & {5, 6,7}, {2, 5, 6, 7})
  507.     same({} & 3, {3})
  508.     same("ABC" & "DEF" & "GHIJ" & {}, "ABCDEFGHIJ")
  509.     same('A' & 'B' & 'C', "ABC")
  510.  
  511.     -- slice tests
  512.     x = "ABCDEFGHIJKLMNOP"
  513.     same(x[1..4], "ABCD")
  514.     y = x[2..5]
  515.     same(y, "BCDE")
  516.     same(x[4..3], {})
  517.     same(x[4..4], "D")
  518.     x[3..5] = "000"
  519.     same(x, "AB000FGHIJKLMNOP")
  520.     x[6..9] = '8'
  521.     same(x, "AB0008888JKLMNOP")
  522.  
  523.     same(floor({1, 2, -3, 4, -5} / 3), {0, 0, -1, 1, -2})
  524.  
  525.     return y
  526. end function
  527.  
  528.  
  529. procedure sequence_ops2()
  530. -- more tests of sequence operations
  531. object x, y
  532.  
  533.     x = "ABCDEFGHIJKLMNOP"
  534.     if find('D', x) != 4 then
  535.     abort()
  536.     end if
  537.     if match("EFGH", x) != 5 then
  538.     abort()
  539.     end if
  540.     if match({"AB", "CD"}, {0, 1, 3, {}, {"AB", "C"}, "AB", "CD", "EF"}) != 6 then
  541.     abort()
  542.     end if
  543.     if compare(x,x) != 0 then
  544.     abort()
  545.     end if
  546.     if compare({}, {}) != 0 then
  547.     abort()
  548.     end if
  549.     y = repeat(repeat(repeat(99, 5), 5), 5)
  550.     if y[3][3][3] != 99 then
  551.     abort()
  552.     end if
  553.     if compare(y[4][4][3..5], repeat(99, 3)) != 0 then
  554.     abort()
  555.     end if
  556.     y[3][2][1..4] = 88
  557.     if compare(y[3][2], {88, 88, 88, 88, 99}) != 0 then
  558.     abort()
  559.     end if
  560. end procedure
  561.  
  562. procedure circularity()
  563. -- test for circular references in internal garbage collector
  564.     object x, y
  565.  
  566.     x = {{"abc", {0, 0, 0}}, "def", 1, 2}
  567.     x[3] = x
  568.     x[1..2] = x[2..3]
  569.     x = append(x, x)
  570.     x = prepend(x, x)
  571.     if compare(x, x) != 0 then
  572.     abort()
  573.     end if
  574.     y = "ABCDE"
  575.     y[2] = repeat(y, 3)
  576.     if compare(y, y) != 0 then
  577.     abort()
  578.     end if
  579. end procedure
  580.  
  581. procedure output()
  582. -- test file output routines
  583.     integer file_no
  584.  
  585.     file_no = open("sanityio.tst", "w")
  586.     if file_no < 0 then
  587.     abort() 
  588.     end if
  589.     puts(file_no, "-- io test\n")
  590.     print(file_no, {1,2,3})
  591.     print(file_no, -99)
  592.     puts(file_no, "{11, {33, {#33}}, 4, 5 }{\t\t}\n")
  593.     puts(file_no, "{}.999 -.999 1.55e00 {11,   22 , {33, 33}, 4, 5  }\n") 
  594.     printf(file_no, "%e", 10000)
  595.     printf(file_no, "%d", -123)
  596.     printf(file_no, "%5.1f", 5+1/2)
  597.     printf(file_no, "%50s\n", {"+99 1001 {1,2,3} 1E-4 {1.002e23,-59e-5,"})
  598.     printf(file_no, "%9e}\t\t-1e-20\t   -.00001e5\n", 59e30)
  599.     puts(file_no, "\"Rob\"\"ert\" \"Craig\"  ")
  600.     puts(file_no, "\"\" \"\\n\" \"\\t\\r\"\t")
  601.     puts(file_no, "\"\\'\\\"\" 'A' '\\n' '\\\"' '\\'' '\\r'\n")
  602.     printf(file_no, "{#%x, ", 291)
  603.     puts(file_no, "\"ABC\"} {'A', 'B', '\\n'}")  
  604.     close(file_no)
  605. end procedure
  606.  
  607. procedure input()
  608. -- test file input routines
  609.     integer file_no
  610.     object line
  611.     integer char
  612.  
  613.     file_no = open("sanityio.tst", "r")
  614.     if file_no < 0 then
  615.     abort()
  616.     end if
  617.     if seek(file_no, 5) then
  618.     abort()
  619.     end if
  620.     if seek(file_no, -1) then
  621.     abort()
  622.     end if
  623.     if seek(file_no, 0) then
  624.     abort()
  625.     end if
  626.     if where(file_no) != 0 then
  627.     abort()
  628.     end if
  629.     line = gets(file_no)
  630.     if compare(line, "-- io test\n") != 0 then
  631.     abort()
  632.     end if
  633.     char = getc(file_no)
  634.     if char != '{' then
  635.     abort()
  636.     end if
  637.     close(file_no)
  638. end procedure
  639.  
  640. procedure testgr()
  641. -- test basic VGA graphics operations
  642.     sequence v
  643.  
  644.     v = video_config()
  645.     if v[VC_XPIXELS] < 100 or v[VC_YPIXELS] < 100 then
  646.     abort()
  647.     end if
  648.     draw_line(1, {{20, 100}, {600, 100}})
  649.     for i = 1 to 200 by 5 do
  650.     pixel(7, {3*i, i})
  651.     if get_pixel({3*i, i}) != 7 then
  652.         abort()
  653.     end if
  654.     end for
  655. end procedure
  656.  
  657. constant TRUE = 1, FALSE = 0
  658.  
  659. procedure testget()
  660. -- test input of Euphoria objects
  661.     object gd
  662.     object x, i
  663.     object results
  664.  
  665.     gd = open("sanityio.tst", "r")
  666.     if gd < 0 or gd > 10 then
  667.     abort()
  668.     end if
  669.     if not sequence(gets(gd)) then
  670.     abort()
  671.     end if
  672.     results = {
  673.      {0, {1,2,3}},
  674.      {0, -99},
  675.      {0, {11, {33, {#33}}, 4, 5}},
  676.      {0, {}},
  677.      {0, {}},
  678.      {0, 0.999},
  679.      {0, -0.999},
  680.      {0, 1.55},
  681.      {0, {11, 22, {33, 33}, 4, 5}},
  682.      {0, 10000},
  683.      {0, -123},
  684.      {0, 5.5},
  685.      {0, 99},
  686.      {0, 1001},
  687.      {0, {1, 2, 3}},
  688.      {0, 0.0001},
  689.      {0, {1.002e+23, -0.00059, 5.9e+31}},
  690.      {0, -1e-20},
  691.      {0, -1},
  692.      {0, "Rob"},
  693.      {0, "ert"},
  694.      {0, "Craig"},
  695.      {0, ""},
  696.      {0, "\n"},
  697.      {0, "\t\r"},
  698.      {0, "\'\""},
  699.      {0, 'A'},
  700.      {0, '\n'},
  701.      {0, '\"'},
  702.      {0, '\''},
  703.      {0, '\r'},
  704.      {0, {#123, "ABC"}},
  705.      {0, {'A', 'B', '\n'}},
  706.      {-#1, 0}
  707.     }
  708.     i = 1
  709.     while TRUE do
  710.     x = get(gd)
  711.     if x[1] = -1 then
  712.         exit
  713.     end if
  714.     same(x, results[i])
  715.     i = i + 1
  716.     end while
  717.     if compare(results[i], {-1, 0}) != 0 then
  718.     puts(2, "wrong number of get values\n")
  719.     end if
  720.     close(gd)
  721. end procedure
  722.  
  723.  
  724. function fib(integer n)
  725. -- fibonacci
  726.     if n < 2 then
  727.     return n
  728.     else
  729.     return fib(n-1) + fib(n-2)
  730.     end if
  731. end function
  732.  
  733. integer rp
  734.  
  735. procedure recursive_proc()
  736. -- a recursively-called procedure
  737.     if rp > 0 then
  738.     rp = rp - 1
  739.     recursive_proc()
  740.     end if
  741. end procedure
  742.  
  743. procedure machine_level()
  744. -- quick test of machine-level routines
  745.     atom addr
  746.  
  747.     addr = allocate(100)
  748.     poke(addr, #C3) -- RET instruction
  749.     if peek(addr) != #C3 then
  750.     abort()
  751.     end if
  752.     call(addr)
  753.     free(addr)
  754.     for x = 0 to +2000000 by 49999 do
  755.         if bytes_to_int(int_to_bytes(x)) != x then
  756.         abort()
  757.         end if
  758.     end for
  759. end procedure
  760.  
  761. global type sorted(sequence x)
  762. -- return TRUE if x is in ascending order
  763.     for i = 1 to length(x)-1 do
  764.     if compare(x[i], x[i+1]) > 0 then
  765.         return FALSE
  766.     end if
  767.     end for
  768.     return TRUE
  769. end type
  770.  
  771. without profile
  772.  
  773. global procedure sanity()
  774. -- main program
  775.     sequence cmd_line
  776.     integer vga
  777.  
  778.     vga = not graphics_mode(18) 
  779.     clear_screen()
  780.     position(12, 20)
  781.     puts(msg, "Euphoria SANITY TEST ... ")
  782.  
  783.     for j = 0 to 8 by 2 do
  784.     if atom(getenv("EUDIR")) then
  785.         puts(1, "EUDIR not set\n")
  786.         abort()
  787.     end if
  788.     cmd_line = command_line()
  789.     if length(cmd_line) < 1 or length(cmd_line) > 10 then
  790.         abort()
  791.     end if
  792.     if length(current_dir()) < 2 then
  793.         abort()
  794.     end if
  795.     if length(dir(".")) < 2 then
  796.         abort()
  797.     end if
  798.     if vga then
  799.         testgr()
  800.     end if
  801.     make_sound()
  802.     same(built_in(), 1)
  803.     atomic_ops()
  804.     overflow()
  805.     floating_pt()
  806.     if compare(sequence_ops(), "BCDE") != 0 then
  807.         puts(msg, "sequence_ops failed\n")
  808.     end if
  809.     sequence_ops2()
  810.     circularity()
  811.     output()
  812.     input()
  813.     testget()
  814.     system("del sanityio.tst", 2)
  815.     machine_level()
  816.     rp = 100
  817.     recursive_proc()
  818.     if rp != 0 then
  819.         puts(msg, "recursive proc failed\n")
  820.     end if
  821.     if fib(20) != 6765 then
  822.         puts(msg, "fib failed\n")
  823.     end if
  824.     if not sorted(sort(-500 + rand(repeat(1000, 1000)))) then
  825.         puts(msg, "standard sort failed\n")
  826.     end if
  827.     if not sorted(sort({"robert", "junko", "dave", "ken", "lurdes"})) then
  828.         puts(msg, "standard general sort failed\n")
  829.     end if
  830.     end for
  831.     printf(msg, "%s\n", {"PASSED (100%)\n\n  <Enter> to continue"})
  832.     if atom(gets(0)) then
  833.     end if
  834.     if graphics_mode(-1) then
  835.     end if
  836.     the_end()    
  837. end procedure
  838.  
  839. integer z
  840.  
  841. -- another for-loop test
  842. z = 0
  843. for j = 1 to 10 do
  844.     z = z + j
  845. end for
  846. if z != 55 then
  847.     abort()
  848. end if
  849.  
  850. sanity()
  851.